package com.inspiration.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.inspiration.entity.Category;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CategoryMapper  extends BaseMapper<Category> {

    /**
     * 查询一级标题
     * @return
     */
    @Select("select  * from category where c_pid is null  ")
    List<Category> listOneCategory();

    /**
     * 查询二级标题
     * @return
     */
    @Select(" select  * from category where c_pid = #{pId} ")
    List<Category> listTwoCategory(long pId);

    @Select(" select count(1) from category where c_pid = #{ccr_category_id} ")
    int childrenCount(long ccr_category_id);

    @Select("  select count(1) from  category_content_relation where ccr_category_id = #{ccr_category_id} ")
    int contentCount(long ccr_category_id);
}
